package com.hua.yuan.ui.data;

import com.hua.yuan.http.Actions;
import com.hua.yuan.http.GetDataTask;
import com.hua.yuan.http.RequestPramsMap;
import com.hua.yuan.http.ShowUrl;
import com.zhy.http.okhttp.callback.StringCallback;

import java.util.Map;

/**
 * Created by huangyang on 2018/5/14.
 * 视频相关的接口请求
 */

public class VideoDataRequest {


    /**
     * 获取轮播图的数据
     *
     * @param token          token
     * @param stringCallback 结果
     */
    public static void getMovieRot(String token, StringCallback stringCallback) {

        Map<String, String> hashMap = new RequestPramsMap.Builder()
                .put("token", token)
                .getHashMap();

        GetDataTask.getDataPost(Actions.MOVIE_ROTATION, hashMap, stringCallback);
    }


    /**
     * 获取首页的数据
     *
     * @param token          token
     * @param stringCallback 结果
     */
    public static void getMovieIndex(String token, StringCallback stringCallback) {

        Map<String, String> hashMap = new RequestPramsMap.Builder()
                .put("token", token)
                .getHashMap();

        GetDataTask.getDataPost(Actions.MOVIE_INDEX, hashMap, stringCallback);


    }

    /**
     * 获取视频列表
     *
     * @param token token
     * @param type  类型，1：火热推荐，2：付费精品，3：包月精选，4：69特价
     * @param from  从第几条开始，默认为0（type为0时，无效）
     * @param num   展示的数量，默认为10
     */
    public static void getMovies(String token, int type, int from, int num, StringCallback stringCallback) {

        Map<String, String> hashMap = new RequestPramsMap.Builder()
                .put("token", token)
                .put("type", String.valueOf(type))
                .put("from", String.valueOf(from))
                .put("num", String.valueOf(num))
                .getHashMap();

        GetDataTask.getDataPost(Actions.GET_MOVIES, hashMap, stringCallback);

    }

    /**
     * 获取视频的详情页
     *
     * @param token          token
     * @param id             视频的id
     * @param stringCallback 结果
     */
    public static void getMovieDetail(String token, String id, StringCallback stringCallback) {

        Map<String, String> hashMap = new RequestPramsMap.Builder()
                .put("token", token)
                .put("id", id)
                .getHashMap();

        GetDataTask.getDataPost(Actions.MOVIE_DETAIL, hashMap, stringCallback);

//        ShowUrl.createPostUrl(Actions.MOVIE_DETAIL, hashMap);

    }

    /**
     * 购买视频
     *
     * @param token          token
     * @param id             视频的id
     * @param stringCallback 结果
     */
    public static void buyMovie(String token, String id, StringCallback stringCallback) {

        Map<String, String> hashMap = new RequestPramsMap.Builder()
                .put("token", token)
                .put("id", id)
                .getHashMap();

        GetDataTask.getDataPost(Actions.MOVIE_BUY, hashMap, stringCallback);



    }

    /**
     * 取消或者收藏视频
     *
     * @param token          token
     * @param type           1：代表收藏，2：代表取消收藏
     * @param id             视频的id
     * @param stringCallback 结果
     */
    public static void movieCollect(String token, String type, String id, StringCallback stringCallback) {
        Map<String, String> hashMap = new RequestPramsMap.Builder()
                .put("token", token)
                .put("id", String.valueOf(id))
                .put("type", type)
                .getHashMap();

        GetDataTask.getDataPost(Actions.MOVIE_COLLECT, hashMap, stringCallback);

        ShowUrl.createPostUrl(Actions.MOVIE_COLLECT, hashMap);


    }

    /**
     * 获取收藏列表
     *
     * @param token          token
     * @param from           从第几条开始，默认为0（type为0时，无效）
     * @param num            展示的数量，默认为10
     * @param stringCallback 结果
     */
    public static void getCollectMovieList(String token, int from, int num, StringCallback stringCallback) {

        Map<String, String> hashMap = new RequestPramsMap.Builder()
                .put("token", token)
                .put("from", String.valueOf(from))
                .put("num", String.valueOf(num))
                .getHashMap();

        GetDataTask.getDataPost(Actions.MOVIE_COLLECT_LIST, hashMap, stringCallback);

    }


    /**
     * 发送评论的接口
     *
     * @param token          token
     * @param id             视频的id
     * @param comment        发送的内容
     * @param stringCallback 结果
     */
    public static void sendComment(String token, String id, String comment, StringCallback stringCallback) {


        Map<String, String> hashMap = new RequestPramsMap.Builder()
                .put("token", token)
                .put("id", id)
                .put("comment", comment)
                .getHashMap();

        GetDataTask.getDataPost(Actions.COMMENT_MOVIES, hashMap, stringCallback);


    }

    /**
     * 评论点赞
     *
     * @param token          token
     * @param id             评论的id
     * @param stringCallback 结果
     */
    public static void videoLike(String token, String id, StringCallback stringCallback) {
        Map<String, String> hashMap = new RequestPramsMap.Builder()
                .put("token", token)
                .put("id", id)
                .getHashMap();

        GetDataTask.getDataPost(Actions.LIKE_MOVIE_COMMENT, hashMap, stringCallback);

    }


}
